import React, {Component} from 'react';
import storageUtil from "../../../utils/storageUtil";
import {Avatar, Button, List} from "antd";

class Orders extends Component {

    state = {
        orders: ''
    }


    componentDidMount() {
        this.$myAxios.get("/order/showAllOrders").then(res=>{
            console.log(res.data)
            this.setState({
                orders:res.data
            })
        })

    }

    render() {
        return (
            <List
                itemLayout="horizontal"
                dataSource={this.state.orders}
                renderItem={item => (
                    <List.Item>
                        <List.Item.Meta
                            avatar={<Avatar src="/static/image/order.png"/>}
                            title={item.theme}
                            description={"创建时间：" + item.createtime}
                        />
                        <Button
                            onClick={()=>{
                                console.log(item)
                                storageUtil.saveOrder(item)
                                this.props.history.push("/manager/qa")
                                console.log(storageUtil.getOrder())
                            }}
                            style={{marginLeft: '10px', marginRight: '10px'}}
                            type="primary"
                        >
                            详细信息
                        </Button>

                    </List.Item>

                )}

            />
        );
    }
}

export default Orders;